/*  var longestCommonPrefix = function(strs) {
    var a = ""
    for(let i =0;i<strs[0].length;i++){
        for(let j =0;j<strs.length-1;j++){
            if(strs[j][i]!==strs[j+1][i]){
                return a
            }
        }
        
        a = a + strs[0][i]
    }
    return a
};  */


/* let a = ["flower","flow","flight"]
console.log(a[0][0]); */
var longestCommonPrefix = function(strs) {
    if(!strs[0]){
        return ""
    }
    if(strs.length==1){
        return strs[0]
    }
    for(let i =0;i<strs[0].length;i++){
        for(let j =0;j<strs.length-1;j++){
            if(strs[j][i]!==strs[j+1][i]){
                return strs[0].slice(0,i)
            }
        }
        
    }
};
console.log(longestCommonPrefix(["a"])); 